package com.c.yinyuezhushou;

import android.app.Application;

import androidx.fragment.app.Fragment;

import com.c.yinyuezhushou.Entity.SetupEntity;
import com.c.yinyuezhushou.MRetrofit.Interceptor;
import com.c.yinyuezhushou.Service.DownService;
import com.c.yinyuezhushou.Service.MusicService;
import com.c.yinyuezhushou.Sql.MyDButil;
import com.umeng.commonsdk.UMConfigure;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.Response;

import static com.umeng.commonsdk.UMConfigure.preInit;

public class MyApplication extends Application {

    private List<String> ck;

    private MusicService musicService;

    private Fragment fragment;

    private DownService downService;

    private SetupEntity setup;

    private MyDButil myDButil;

    private OkHttpClient okHttpClient;

    public MyDButil getMyDButil() {
        return myDButil;
    }

    public void setMyDButil(MyDButil myDButil) {
        this.myDButil = myDButil;
    }

    public SetupEntity getSetup() {
        return setup;
    }

    public void setSetup(SetupEntity setup) {
        this.setup = setup;
    }

    public DownService getDownService() {
        return downService;
    }

    public void setDownService(DownService downService) {
        this.downService = downService;
    }

    public MusicService getMusicService() {
        return musicService;
    }

    public void setMusicService(MusicService musicService) {
        this.musicService = musicService;
    }

    public Fragment getFragment() {
        return fragment;
    }

    public void setFragment(Fragment fragment) {
        this.fragment = fragment;
    }

    public List<String> getCk() {
        return ck;
    }

    public void setCk(List<String> ck) {
        this.ck = ck;
        okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10, TimeUnit.SECONDS)
                .writeTimeout(10,TimeUnit.SECONDS)
                .readTimeout(30,TimeUnit.SECONDS)
                .addInterceptor(new Interceptor(ck))
                .build();
    }

    public OkHttpClient getOkHttpClient() {
        return okHttpClient;
    }

    public void setOkHttpClient(OkHttpClient okHttpClient) {
        this.okHttpClient = okHttpClient;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        setup = new SetupEntity(this);

        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE,"huluxia");
    }
}
